﻿using System;

using enyo;

namespace com.RexToy
{
    public class PresView : ConverterView
    {
        private object[] components = new object[]{ 
            new {kind= ControlKind.BasicScroller, 
                components=new object[] {
                    new {kind=ControlKind.RowGroup, 
                        components= new object[]{
				            new {name= "kp", richContent= false, kind = ControlKind.Input, onblur="blur",
                                    components=new object[]{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Kpa")}
                                    }
                            },
                            new {name= "p", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components= new object[]{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Pa")}
				                    }
                            },
				            new {name= "atm", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Atm")}
				                   }
				            },
                            new {name= "b", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Bar")}
				                   }
				            },
                            new {name= "mb", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("mBar")}
				                   }
				            },
                            new {name= "mmHg", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("mmHg")}
				                   }
				            }
			            }                    
		            }      
                }
            }
        };

        public override void Create()
        {
            this.Inherited(Arguments.Value);

            this.units = new string[] { "p", "kp", "atm", "b", "mb", "mmHg" };
            this.baseUnit = "p";

            this.fomular = new object();
            this.fomular["p->p"] = "p";
            this.fomular["p->kp"] = "p/1000";
            this.fomular["kp->p"] = "kp*1000";
            this.fomular["p->atm"] = "p/101325";
            this.fomular["atm->p"] = "atm*101325";
            this.fomular["p->b"] = "p/100000";
            this.fomular["b->p"] = "b*100000";
            this.fomular["p->mb"] = "p/100";
            this.fomular["mb->p"] = "mb*100";
            this.fomular["p->mmHg"] = "p*0.0075006168";
            this.fomular["mmHg->p"] = "mmHg*133.32237";
        }
    }
}
